<?php
/**
 * Created by PhpStorm.
 * User: mr.hao
 * Date: 2018/8/13
 * Time: 17:30
 */

namespace Modules\Basic;


use Modules\Basic\Entities\BaseReply;


class Response
{
    public function handle($data)
    {
        $instance = \Houdunwang\WeChat\WeChat::instance('message');
//关注用户扫描二维码事件
//通过传递过来的规则数据找到对应的回复内容数据
        $content = json_decode(BaseReply::where('role_id',$data['id'])->first()->content,true);
//向用户回复消息
        return $instance->text(array_random($content)['content']);
    }
}